#!/usr/bin/env ruby
# -*- coding: us-ascii -*-
# Elizabeth Wiethoff 2008

require File.join(File.dirname(__FILE__), '..', 'auxil', 'osdetect')

########################################

class String
  def unixpath
    gsub %r'\\(?! )', '/'
  end
  
  def slashpath
    if $MSWIN
      gsub %r'/', '\\'
    else
      unixpath
    end
  end
end

########################################

class Array
  def unixpath!
    map! { |path| path.unixpath }
  end
  
  def unixpath
    dup.unixpath!
  end
  
  def slashpath!
    map! { |path| path.slashpath }
  end
  
  def slashpath
    dup.slashpath!
  end
end

########################################

if $0 == __FILE__
  p $MSWIN, $/ ; puts
  
  p1 = 'C:\\Program Files\\Corel\\WordPerfect Office 2002\\'
  p2 = 'C:\\Program Files/Corel/WordPerfect Office 2002/'
  p3 = '/System\\ Folder/Scripting\\ Additions/'
  p4 = '\\System Folder\\Scripting Additions\\'
  puts p1, p2, p3, p4 ; puts
  
  puts p2.slashpath
  puts p2.unixpath
  puts p3.unixpath
  puts p4.unixpath ; puts
  
  a = [p2, p3, p4]
  puts a.slashpath ; puts
  puts a.slashpath! ; puts
  puts a.unixpath ; puts
  puts a.unixpath! ; puts
end
